package com.hurl.library.hibernate;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

import com.hurl.library.util.StringUtils;

public class Table2BOStrategy extends DelegatingReverseEngineeringStrategy{

	/**
	 * 删除开头的字符“T”，最后加上“BO”
	 */
	@Override
	public String tableToClassName(TableIdentifier tableIdentifier) {
		String name = super.tableToClassName(tableIdentifier);
		String[] a = name.split("\\.");
		if(a[a.length-1].startsWith("T")){
			a[a.length-1]=a[a.length-1].substring(1);
		}
		return StringUtils.concat(a, ".")+"BO";
	}

	public Table2BOStrategy(
			ReverseEngineeringStrategy delegate) {
		super(delegate);
	}
}
